import {
    createStore,
    combineReducers,
    applyMiddleware
} from 'redux';
import thunk from 'redux-thunk';

const loginReducer = (state={isLogin:false},action)=>{
    switch (action.type) {
        case 'login':
            return {...state,isLogin: action.value};
        default:
            return state;
    }
}
const homeReducer = (state={list:[1,2]},action)=>{
    switch (action.type) {
        case 'add_item':
            return {...state,list: [action.payload,...state.list]};
        default:
            return state;
    }
}
const rootReducer = combineReducers({
    login:loginReducer,
    home:homeReducer
})
const store = createStore( 
    rootReducer, 
    applyMiddleware(thunk)
);
export default store;